package com.hl.controller.shangpin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.hl.domain.ProductApproval;
import com.hl.service.IProductApprovalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商品审核Controller
 * 
 * @author ruoyi
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/approval")
public class ProductApprovalController extends BaseController
{
    @Autowired
    private IProductApprovalService productApprovalService;

    /**
     * 查询商品审核列表
     */
    @RequiresPermissions("shangpin:approval:list")
    @GetMapping("/list")
    public TableDataInfo list(ProductApproval productApproval)
    {
        startPage();
        List<ProductApproval> list = productApprovalService.selectProductApprovalList(productApproval);
        return getDataTable(list);
    }

    /**
     * 导出商品审核列表
     */
    @RequiresPermissions("shangpin:approval:export")
    @Log(title = "商品审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductApproval productApproval)
    {
        List<ProductApproval> list = productApprovalService.selectProductApprovalList(productApproval);
        ExcelUtil<ProductApproval> util = new ExcelUtil<ProductApproval>(ProductApproval.class);
        util.exportExcel(response, list, "商品审核数据");
    }

    /**
     * 获取商品审核详细信息
     */
    @RequiresPermissions("shangpin:approval:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(productApprovalService.selectProductApprovalById(id));
    }

    /**
     * 新增商品审核
     */
    @RequiresPermissions("shangpin:approval:add")
    @Log(title = "商品审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductApproval productApproval)
    {
        return toAjax(productApprovalService.insertProductApproval(productApproval));
    }

    /**
     * 修改商品审核
     */
    @RequiresPermissions("shangpin:approval:edit")
    @Log(title = "商品审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductApproval productApproval)
    {
        return toAjax(productApprovalService.updateProductApproval(productApproval));
    }

    /**
     * 删除商品审核
     */
    @RequiresPermissions("shangpin:approval:remove")
    @Log(title = "商品审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(productApprovalService.deleteProductApprovalByIds(ids));
    }
}
